package com.xxx.modules.controller;;
import com.xxx.modules.service.CameraService;
import com.xxx.modules.entity.Camera;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import com.github.pagehelper.PageInfo;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
import com.xxx.modules.utils.Result;
import com.xxx.modules.utils.ResultUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * camera
 *
 * @author 北易航
 * @since 1.0.0 2023-01-21
 */
@RestController
@RequestMapping("/common/camera")
@Api(tags="camera")
public class CameraController {
    @Autowired
    private CameraService cameraService;

    /**
    *  获取所有监控信息
    * @param pageNum
    * @param pageSize
    * @param camera
    * @return
    */

    @GetMapping("/getCameraInfo")
    @ApiOperation("获取所有监控信息")
    public Result getCameraInfo(Camera camera, @RequestParam(value="pageNum",defaultValue = "1") Integer pageNum,
                                      @RequestParam(value="pageSize",defaultValue = "10") Integer pageSize){
        PageInfo<Camera> data = cameraService.selectCameraInfo(camera,pageNum,pageSize);
        return ResultUtil.success(1,"成功",data);
    }

    /**
    * 保存监控信息
    * @param camera
    * @return
    */
    @PostMapping("/saveCameraInfo")
    @ApiOperation("保存监控信息")
    public Result saveCameraInfo(@RequestBody Camera camera){
        cameraService.saveCameraInfo(camera);
        return ResultUtil.success(1,"成功",null);
    }


    /**
     * 更新监控信息
     * @param camera
     * @return
     */

    @PutMapping("/updateCameraInfo")
    @ApiOperation("更新监控信息")
    public Result updateCameraInfo(@RequestBody Camera camera){
        cameraService.updateCameraInfo(camera);
        return ResultUtil.success(1,"成功",null);
    }

    /**
     * 根据id删除监控信息
     * @param id
     * @return
     */
    @DeleteMapping("/delCameraInfo")
    @ApiOperation("根据id删除监控信息")
    public Result delCameraInfo(Integer id){
        cameraService.delCameraInfo(id);
        return ResultUtil.success(1,"成功",null);
    }

    /**
     * 根据id集合批量删除监控信息
     * @param idList
     * @return
     */
    @DeleteMapping("/delBatchCameraInfo")
    @ApiOperation("根据id集合批量删除监控信息")
    public Result delBatchCameraInfo(String idList){
        cameraService.delBatchCameraInfo(idList);
        return ResultUtil.success(1,"成功",null);
    }

}